<template>
  <a-modal
    width='437px'
    title='是否确定删除该交付物？'
    cancelText="取消"
    okText="确定"
    :visible="visible"
    @ok="handleOk"
    :confirmLoading="confirmLoading"
    @cancel="handleCancel">
    <span>删除的交付物将不可恢复，需重新上传</span>
  </a-modal>
</template>
<script>
import { mapGetters } from 'vuex'
import { deleteObjForAllVersion } from "@/api/fileSingle.js"
import copyACtion from '@/views/singleProject/fileSingle/el-common-js/copy'
export default {
  mixins: [copyACtion],
  data() {
    return {
      confirmLoading: false,
      visible: false,
    }
  },
  computed: {
    ...mapGetters({
      'fileSingleData': 'fileSingle'
    })
  },
  props: {
    sessionData: {
      type: Array,
      default: () => []
    },//存入的session
  },
  methods: {
    /**
     * 确定按钮事件
     * 功能： 删除交付物
     */
    handleOk() {
      this.confirmLoading = true
      deleteObjForAllVersion({oids: this.cycleID(this.sessionData)}).then((res) => {
        if (res && res.data.success) {
          // this.$emit('initTableData')
          //跳转至文件树，并关闭文档签审页面
          let tabArrNew = JSON.parse(sessionStorage.getItem('tabArr'))
          tabArrNew = tabArrNew.filter((rec) => {
            return rec.title !== '文档签审' && rec.title !== '查看交付物'
          })
          this.$store.commit('SET_TABS', tabArrNew)
          this.$router.push('/single/fileSingle');
          this.visible = false
          this.$message.success('删除成功')
          this.$emit('initTableData')
        } else {
          this.$message.error(res.data.message)
        }
        this.confirmLoading = false
      })
    },
    /**
     * 取消按钮事件
     */
    handleCancel(e) {
      this.visible = false;
    },
    /**
     * 开启弹窗
     * key 上级需要开启那个弹窗的key
     */
    openModal (start) {
      this.visible = start
    }
  }
}
</script>
<style lang="less" scoped>
/deep/.ant-modal-content {
  padding: 20px;
  box-sizing: border-box;
  .ant-modal-header {
    padding: 0;
    border: none;
    box-sizing: border-box;
    .ant-modal-title {
      display: flex;
      align-content: center;
      font-size: 16px;
      color: #333333;
      line-height: 24px;
      &::before {
        margin: 2px 10px 0 0;
        content: '';
        display: inline-block;
        width: 20px;
        height: 20px;
        background-image: url('./../../../../assets/img/Warning.svg');
      }
    }
  }
  .ant-modal-body {
    min-height: 70px;
    margin: 10px 0;
    padding: 0px 20px;
    font-size: 14px;
    color: #666666;
    line-height: 22px;
  }
  .ant-modal-footer {
    padding: 0;
    border: none;
    .ant-btn {
      width: 72px;
    }
  }
}
</style>